package cn.zn.modules.budget.cur.service.impl;

import cn.hutool.core.util.StrUtil;
import cn.zn.framework.common.utils.PageUtils;
import cn.zn.framework.common.utils.Query;
import cn.zn.modules.budget.cur.dao.TBudgetIncomeTagMapper;
import cn.zn.modules.budget.cur.entity.TBudgetIncomeTag;
import cn.zn.modules.budget.cur.service.TBudgetIncomeTagService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("tBudgetIncomeTagService")
public class TBudgetIncomeTagServiceImpl extends ServiceImpl<TBudgetIncomeTagMapper, TBudgetIncomeTag> implements TBudgetIncomeTagService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String incomeId = "";
        if (params.containsKey("incomeId")) {
            incomeId = params.get("incomeId").toString();
        }

        IPage<TBudgetIncomeTag> page = this.page(
                new Query<TBudgetIncomeTag>().getPage(params),
                new QueryWrapper<TBudgetIncomeTag>()
                        .eq(StrUtil.isNotBlank(incomeId), "T_BUDGET_INCOME_ID_", incomeId)
                        .orderByDesc("CREATE_TIME_")
        );

        return new PageUtils(page);
    }

}
